package com.hqyj.controller;


import com.hqyj.pojo.Rows;
import com.hqyj.service.IRowsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;

/**
 * <p>
 * 原料表 前端控制器
 * </p>
 *
 * @author rock
 * @since 2021-10-21
 */
@RestController
@RequestMapping("/rows")
public class RowsController {

    //注入依赖
    @Autowired
    IRowsService rowsService;

    //加载分页页面
    @RequestMapping("/rowsList")
    public HashMap<String,Object> rowsList(Rows rows){
        return rowsService.select(rows);
    }

    //增加
    @RequestMapping("/add")
    public HashMap<String,Object> rowsAdd(Rows rows){
        return rowsService.rowsAdd(rows);
    }

    //删除
    @RequestMapping("/del")
    public HashMap<String ,Object> rowsDel(Rows rows){
        System.out.println("delete:"+rows);
        return rowsService.del(rows);
    }

    //修改
    @RequestMapping("/update")
    public HashMap<String ,Object> rowsUpdate(Rows rows){
        System.out.println("update:"+rows);
        return rowsService.update(rows);
    }

    //购买
    @RequestMapping("/purchase")
    public HashMap<String ,Object> purchaseOne(Rows rows, HttpSession session){
        System.err.println(rows);
        return rowsService.purchaseOne(rows,session);
    }
 }

